<template>
  <div v-if="visible" class="modal-overlay">
    <div class="modal-box">
      <h3 class="modal-title">{{ title }}</h3>
      <p class="modal-message">{{ message }}</p>
      <button @click="closeModal" class="modal-close">关闭</button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { defineProps, defineEmits } from 'vue';

defineProps({
  title: String,
  message: String,
  visible: Boolean,
});

const emit = defineEmits(['close']);

function closeModal() {
  // 触发关闭事件
  emit('close');
}
</script>

<style scoped>
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-box {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  text-align: center;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: bold;
}

.modal-message {
  margin-top: 10px;
}

.modal-close {
  margin-top: 15px;
  padding: 8px 16px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.modal-close:hover {
  background: #0056b3;
}
</style>

  